﻿using System;
using UnityEngine;
using System.Collections;

public class WaitForAnimation : SparkCoroutine{

    System.Object[] animations;

    public WaitForAnimation(params System.Object[] animations)
    {
        this.animations = animations;
    }

    public override bool finished
    {
        get
        {
            foreach (System.Object item in animations)
            {
                if (item is UITweener)
                {
                    if (((UITweener)item).enabled)
                    {
                        return false;
                    }
                }else if (item is Animator)
                {
                    if (((Animator)item).GetCurrentAnimatorStateInfo(0).normalizedTime < 1f)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}
